package com.atstudy.buffer;

import java.io.*;
import java.util.Date;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2022/12/28 15:28
 * @copyright: 博为峰
 */
public class BufferedReaderWriterDemo {
    public static void main(String[] args) throws IOException {
//        m1();
        FileReader fileReader = new FileReader("C:\\Users\\admin\\Desktop\\java29\\io\\MYSQL5.7安装.docx");
        BufferedReader bufferedReader = new BufferedReader(fileReader);

        FileWriter fileWriter = new FileWriter("C:\\Users\\admin\\Desktop\\java29\\io2\\MYSQL5.7安装.docx");
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
        //开始
       /* Date start = new Date();
        long startTime = start.getTime();*/
        long startTime = System.currentTimeMillis();
        String line = null;
        while ((line = bufferedReader.readLine()) != null) {
            bufferedWriter.write(line);
            bufferedWriter.newLine();//换行 /t
        }

        //结束
        /*Date end = new Date();
        long endTime = end.getTime();*/
        long endTime = System.currentTimeMillis();

        long l = endTime - startTime;
        System.out.println("l = " + l);

        bufferedReader.close();
        bufferedWriter.close();
    }

    private static void m1() throws IOException {
        FileReader fileReader = new FileReader("C:\\Users\\admin\\Desktop\\java29\\io\\f01.txt");
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        String line = bufferedReader.readLine();
        System.out.println(line);

        FileWriter fileWriter = new FileWriter("C:\\Users\\admin\\Desktop\\java29\\io2\\f02.txt");
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
        bufferedWriter.write(line);

        bufferedReader.close();
        bufferedWriter.close();
    }
}
